import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * @author anan
 * @create 2022-03-24 16:57
 */
public class MyFileWriter {
    public static void WriteStringToFile2(List<Map<String, Map<String, Integer>>> res, String filePath) {
        try {
            FileWriter fw = new FileWriter(filePath, true);
            BufferedWriter bw = new BufferedWriter(fw);

            for(Map<String, Map<String, Integer>> map : res){
                for (Map.Entry<String, Map<String, Integer>> mapson : map.entrySet()) {

                    StringBuilder sb = new StringBuilder();
                    String clientId = mapson.getKey();
                    Map<String, Integer> value = mapson.getValue();
                    sb.append(clientId).append(":");
                    for (Map.Entry<String, Integer> entry2 : value.entrySet()) {
                        sb.append("<").append(entry2.getKey()).append(",").append(entry2.getValue()).append(">").append(",");
                    }
                    sb.deleteCharAt(sb.length() - 1);
                    bw.newLine();
                    bw.write(sb.toString());
                }
            }
            bw.close();
            fw.close();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
